<?php
require_once FOREGROUND_MOBILE_COMMON_ACTION_DIR . '/default.php';

class foreground_mobile_member_common_action extends foreground_mobile_default_common_action
{    
    protected $_if_require_login = true;
    
    
    public function run()
    {
        $this->_pre_run();
        if(self::$_view_status < 0){
            return;
        }
    
        $this->_current_page_run();
    
        $this->_post_run();
    }
    
    protected function _pre_run()
    {
        parent::_pre_run();
    
        $this->check_login();
    }
    
    protected function check_login()
    {
        if($this->_if_require_login){
            $result = array('status' => 0, 'message' => '', 'data' => array());
    
            $session_member_info = self::$data['session_member_info'];
            if(empty($session_member_info['id'])){
                $result['status']  = -401;
                $result['message'] = '请先登录';
                 
                $this->set_view_status($result['status']);
                $this->set_view_message($result['message']);
    
                $url = $this->get_url(array('route' => 'member_mobile_login'), true);
                echo '<script type="text/javascript">window.top.location.replace("'. $url . '");</script>';
            }
        }
    }
}